<template>
  <div class="flnanp" @click="gettitl">
    <loading v-if="isLoading"></loading>
    <section class="m-lib">
      <h3>
        <router-link to><em class="sep"></em>男生小说</router-link>
      </h3>
      <div class="table">
        <ul>
          <li v-for="(item, l) in fl_listn">
            <router-link to :index="item.url">{{ item.name }}</router-link>
          </li>
        </ul>
      </div>
    </section>
    <section class="m-lib men">
      <h3>
        <router-link to><em class="sep"></em>女生小说</router-link>
      </h3>
      <div class="table">
        <ul>
          <li v-for="(item, l) in fl_listnv">
            <router-link to :index="item.url">{{ item.name }}</router-link>
          </li>
        </ul>
      </div>
    </section>
    <section class="m-lib men">
      <h3>
        <router-link to><em class="sep"></em>图书书库</router-link>
      </h3>
      <div class="table">
        <ul>
          <li v-for="(item, l) in fl_listcb">
            <router-link to :index="item.url">{{ item.name }}</router-link>
          </li>
        </ul>
      </div>
    </section>
  </div>
</template>
<script>
import { flFunc, reFunc } from "@/request/index";
import Loading from "@/components/loading/indexlist.vue";
export default {
  data() {
    return {
      fl_listn: [],
      fl_listnv: [],
      fl_listcb: [],
      url: "",
      title: "",
      isLoading: true,
    };
  },
  components: {
    Loading
  },
  methods: {
    async csfe() {
      await flFunc().then((res) => {
        let fln = res.books[0].node[0];
        let flnv = res.books[1].node[0];
        let flcb = res.books[2].node[0];
        this.url1=fln.url
        this.url2=flnv.url
        this.url3=flcb.url
        reFunc(fln.url).then((lisn) => {
          // console.log(lisn)
          let nlist = lisn.list[0].labels;
          this.fl_listn = nlist.map((itemn) => {
            return itemn;
          });
        }).catch(err => {
          console.log("请求失败...");
        });
        reFunc(flnv.url).then((lisnv) => {
          let nvlist = lisnv.list[0].labels;
          this.fl_listnv = nvlist.map((itemnv) => {
            return itemnv;
          });
          // console.log(this.fl_listnv);
        }).catch(err => {
          console.log("请求失败...");
        });
        reFunc(flcb.url).then((liscb) => {
          let cblist = liscb.list[0].labels;
          this.fl_listcb = cblist.map((itemcb) => {
            return itemcb;
          });
          // console.log(this.fl_listcb);
        }).catch(err => {
          console.log("请求失败...");
        });
        this.isLoading = false;
      }).catch(err => {
          console.log("请求失败...");
        });
    },
    gettitl(e) {
      if (e.target.tagName === "A") {
        this.title = e.target.textContent;
        // console.log( e.target.getAttribute('index'))
        this.url= e.target.getAttribute('index')
      }
      let titles= this.title
      let urls = this.url
      this.$router.push(`/fl/fls?list_title=${titles}&url=${urls}&pay=0&bookStatus=0&wordCount=0&sort=1`);
    },
  },
  created() {
    this.csfe();
  },
};
</script>
<style lang="scss">
@import url(../../static/css/reset.css);
.flnanp {
  box-sizing: border-box;
  background: #f5f5f5;
  .m-lib {
    background-color: #fff;
    margin-bottom: 8px;
    padding: 15px;
    h3 {
      height: 19px;
      line-height: 19px;
      font-size: 16px;
      font-weight: bold;
      a {
        text-align: start;
        display: block;
        font-size: 18px;
        color: #ed6460;
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        .sep {
          font-style: normal;
          display: inline-block;
          background: #ed6460;
          border-radius: 3px;
          width: 2.5px;
          height: 12px;
          margin-right: 6px;
        }
      }
    }
    .table {
      width: 100%;
      margin: 5px 0 0;
      padding-top: 10px;
      ul {
        display: table-row-group;
        text-align: center;
        li {
          float: left;
          width: 33%;
          text-align: center;
          height: 50px;
          font-size: 14px;
          a {
            display: block;
            width: 85px;
            margin: 10px auto;
            height: 30px;
            line-height: 30px;
            text-overflow: ellipsis;
            background: #f5f5f5;
            color: #3b352d;
            border-radius: 4px;
            outline: none;
          }
        }
      }
    }
  }
}
</style>
  